package com.abc.vo;

import com.baomidou.mybatisplus.annotations.TableField;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author luo
 */
public class ExampleVo implements Serializable {

    private static final long serialVersionUID = 8693145530249113989L;
    /**
     * 主键
     * <p>
     * isNullAble:0
     */
    private Integer id;

    /**
     * isNullAble:1
     */
    private String name;

    /**
     * isNullAble:1
     */
    private Integer banner;

    /**
     * isNullAble:1
     */
    private String richText;

    /**
     * isNullAble:1
     */
    private String lowerCase;


    private String imagePath;

    private int order;


    private Integer type;


    private Integer size;


    private String banner2;
    private Integer top;

    public String getBanner2() {
        return banner2;
    }

    public void setBanner2(String banner2) {
        this.banner2 = banner2;
    }

    public Integer getTop() {
        return top;
    }

    public void setTop(Integer top) {
        this.top = top;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getSize() {
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public int getOrder() {
        return order;
    }

    public void setOrder(int order) {
        this.order = order;
    }

    public String getImagePath() {
        return imagePath;
    }

    public void setImagePath(String imagePath) {
        this.imagePath = imagePath;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return this.id;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return this.name;
    }

    public void setBanner(Integer banner) {
        this.banner = banner;
    }

    public Integer getBanner() {
        return this.banner;
    }

    public void setRichText(String richText) {
        this.richText = richText;
    }

    public String getRichText() {
        return this.richText;
    }

    public void setLowerCase(String lowerCase) {
        this.lowerCase = lowerCase;
    }

    public String getLowerCase() {
        return this.lowerCase;
    }

    @Override
    public String toString() {
        return "ExampleVo{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", banner=" + banner +
                ", richText='" + richText + '\'' +
                ", lowerCase='" + lowerCase + '\'' +
                ", imagePath='" + imagePath + '\'' +
                '}';
    }

    public static Builder Build() {
        return new Builder();
    }

    public static ConditionBuilder ConditionBuild() {
        return new ConditionBuilder();
    }

    public static UpdateBuilder UpdateBuild() {
        return new UpdateBuilder();
    }

    public static QueryBuilder QueryBuild() {
        return new QueryBuilder();
    }

    public static class UpdateBuilder {

        private ExampleVo set;

        private ConditionBuilder where;

        public UpdateBuilder set(ExampleVo set) {
            this.set = set;
            return this;
        }

        public ExampleVo getSet() {
            return this.set;
        }

        public UpdateBuilder where(ConditionBuilder where) {
            this.where = where;
            return this;
        }

        public ConditionBuilder getWhere() {
            return this.where;
        }

        public UpdateBuilder build() {
            return this;
        }
    }

    public static class QueryBuilder extends ExampleVo {
        /**
         * 需要返回的列
         */
        private Map<String, Object> fetchFields;

        public Map<String, Object> getFetchFields() {
            return this.fetchFields;
        }

        private List<Integer> idList;

        public List<Integer> getIdList() {
            return this.idList;
        }

        private Integer idSt;

        private Integer idEd;

        public Integer getIdSt() {
            return this.idSt;
        }

        public Integer getIdEd() {
            return this.idEd;
        }

        private List<String> nameList;

        public List<String> getNameList() {
            return this.nameList;
        }


        private List<String> fuzzyName;

        public List<String> getFuzzyName() {
            return this.fuzzyName;
        }

        private List<String> rightFuzzyName;

        public List<String> getRightFuzzyName() {
            return this.rightFuzzyName;
        }

        private List<Integer> bannerList;

        public List<Integer> getBannerList() {
            return this.bannerList;
        }

        private Integer bannerSt;

        private Integer bannerEd;

        public Integer getBannerSt() {
            return this.bannerSt;
        }

        public Integer getBannerEd() {
            return this.bannerEd;
        }

        private List<String> richTextList;

        public List<String> getRichTextList() {
            return this.richTextList;
        }


        private List<String> fuzzyRichText;

        public List<String> getFuzzyRichText() {
            return this.fuzzyRichText;
        }

        private List<String> rightFuzzyRichText;

        public List<String> getRightFuzzyRichText() {
            return this.rightFuzzyRichText;
        }

        private List<String> lowerCaseList;

        public List<String> getLowerCaseList() {
            return this.lowerCaseList;
        }


        private List<String> fuzzyLowerCase;

        public List<String> getFuzzyLowerCase() {
            return this.fuzzyLowerCase;
        }

        private List<String> rightFuzzyLowerCase;

        public List<String> getRightFuzzyLowerCase() {
            return this.rightFuzzyLowerCase;
        }

        private QueryBuilder() {
            this.fetchFields = new HashMap<>();
        }

        public QueryBuilder idBetWeen(Integer idSt, Integer idEd) {
            this.idSt = idSt;
            this.idEd = idEd;
            return this;
        }

        public QueryBuilder idGreaterEqThan(Integer idSt) {
            this.idSt = idSt;
            return this;
        }

        public QueryBuilder idLessEqThan(Integer idEd) {
            this.idEd = idEd;
            return this;
        }


        public QueryBuilder id(Integer id) {
            setId(id);
            return this;
        }

        public QueryBuilder idList(Integer... id) {
            this.idList = solveNullList(id);
            return this;
        }

        public QueryBuilder idList(List<Integer> id) {
            this.idList = id;
            return this;
        }

        public QueryBuilder fetchId() {
            setFetchFields("fetchFields", "id");
            return this;
        }

        public QueryBuilder excludeId() {
            setFetchFields("excludeFields", "id");
            return this;
        }

        public QueryBuilder fuzzyName(List<String> fuzzyName) {
            this.fuzzyName = fuzzyName;
            return this;
        }

        public QueryBuilder fuzzyName(String... fuzzyName) {
            this.fuzzyName = solveNullList(fuzzyName);
            return this;
        }

        public QueryBuilder rightFuzzyName(List<String> rightFuzzyName) {
            this.rightFuzzyName = rightFuzzyName;
            return this;
        }

        public QueryBuilder rightFuzzyName(String... rightFuzzyName) {
            this.rightFuzzyName = solveNullList(rightFuzzyName);
            return this;
        }

        public QueryBuilder name(String name) {
            setName(name);
            return this;
        }

        public QueryBuilder nameList(String... name) {
            this.nameList = solveNullList(name);
            return this;
        }

        public QueryBuilder nameList(List<String> name) {
            this.nameList = name;
            return this;
        }

        public QueryBuilder fetchName() {
            setFetchFields("fetchFields", "name");
            return this;
        }

        public QueryBuilder excludeName() {
            setFetchFields("excludeFields", "name");
            return this;
        }

        public QueryBuilder bannerBetWeen(Integer bannerSt, Integer bannerEd) {
            this.bannerSt = bannerSt;
            this.bannerEd = bannerEd;
            return this;
        }

        public QueryBuilder bannerGreaterEqThan(Integer bannerSt) {
            this.bannerSt = bannerSt;
            return this;
        }

        public QueryBuilder bannerLessEqThan(Integer bannerEd) {
            this.bannerEd = bannerEd;
            return this;
        }


        public QueryBuilder banner(Integer banner) {
            setBanner(banner);
            return this;
        }

        public QueryBuilder bannerList(Integer... banner) {
            this.bannerList = solveNullList(banner);
            return this;
        }

        public QueryBuilder bannerList(List<Integer> banner) {
            this.bannerList = banner;
            return this;
        }

        public QueryBuilder fetchBanner() {
            setFetchFields("fetchFields", "banner");
            return this;
        }

        public QueryBuilder excludeBanner() {
            setFetchFields("excludeFields", "banner");
            return this;
        }

        public QueryBuilder fuzzyRichText(List<String> fuzzyRichText) {
            this.fuzzyRichText = fuzzyRichText;
            return this;
        }

        public QueryBuilder fuzzyRichText(String... fuzzyRichText) {
            this.fuzzyRichText = solveNullList(fuzzyRichText);
            return this;
        }

        public QueryBuilder rightFuzzyRichText(List<String> rightFuzzyRichText) {
            this.rightFuzzyRichText = rightFuzzyRichText;
            return this;
        }

        public QueryBuilder rightFuzzyRichText(String... rightFuzzyRichText) {
            this.rightFuzzyRichText = solveNullList(rightFuzzyRichText);
            return this;
        }

        public QueryBuilder richText(String richText) {
            setRichText(richText);
            return this;
        }

        public QueryBuilder richTextList(String... richText) {
            this.richTextList = solveNullList(richText);
            return this;
        }

        public QueryBuilder richTextList(List<String> richText) {
            this.richTextList = richText;
            return this;
        }

        public QueryBuilder fetchRichText() {
            setFetchFields("fetchFields", "richText");
            return this;
        }

        public QueryBuilder excludeRichText() {
            setFetchFields("excludeFields", "richText");
            return this;
        }

        public QueryBuilder fuzzyLowerCase(List<String> fuzzyLowerCase) {
            this.fuzzyLowerCase = fuzzyLowerCase;
            return this;
        }

        public QueryBuilder fuzzyLowerCase(String... fuzzyLowerCase) {
            this.fuzzyLowerCase = solveNullList(fuzzyLowerCase);
            return this;
        }

        public QueryBuilder rightFuzzyLowerCase(List<String> rightFuzzyLowerCase) {
            this.rightFuzzyLowerCase = rightFuzzyLowerCase;
            return this;
        }

        public QueryBuilder rightFuzzyLowerCase(String... rightFuzzyLowerCase) {
            this.rightFuzzyLowerCase = solveNullList(rightFuzzyLowerCase);
            return this;
        }

        public QueryBuilder lowerCase(String lowerCase) {
            setLowerCase(lowerCase);
            return this;
        }

        public QueryBuilder lowerCaseList(String... lowerCase) {
            this.lowerCaseList = solveNullList(lowerCase);
            return this;
        }

        public QueryBuilder lowerCaseList(List<String> lowerCase) {
            this.lowerCaseList = lowerCase;
            return this;
        }

        public QueryBuilder fetchLowerCase() {
            setFetchFields("fetchFields", "lowerCase");
            return this;
        }

        public QueryBuilder excludeLowerCase() {
            setFetchFields("excludeFields", "lowerCase");
            return this;
        }

        private <T> List<T> solveNullList(T... objs) {
            if (objs != null) {
                List<T> list = new ArrayList<>();
                for (T item : objs) {
                    if (item != null) {
                        list.add(item);
                    }
                }
                return list;
            }
            return null;
        }

        public QueryBuilder fetchAll() {
            this.fetchFields.put("AllFields", true);
            return this;
        }

        public QueryBuilder addField(String... fields) {
            List<String> list = new ArrayList<>();
            if (fields != null) {
                for (String field : fields) {
                    list.add(field);
                }
            }
            this.fetchFields.put("otherFields", list);
            return this;
        }

        @SuppressWarnings("unchecked")
        private void setFetchFields(String key, String val) {
            Map<String, Boolean> fields = (Map<String, Boolean>) this.fetchFields.get(key);
            if (fields == null) {
                fields = new HashMap<>();
            }
            fields.put(val, true);
            this.fetchFields.put(key, fields);
        }

        public ExampleVo build() {
            return this;
        }
    }


    public static class ConditionBuilder {
        private List<Integer> idList;

        public List<Integer> getIdList() {
            return this.idList;
        }

        private Integer idSt;

        private Integer idEd;

        public Integer getIdSt() {
            return this.idSt;
        }

        public Integer getIdEd() {
            return this.idEd;
        }

        private List<String> nameList;

        public List<String> getNameList() {
            return this.nameList;
        }


        private List<String> fuzzyName;

        public List<String> getFuzzyName() {
            return this.fuzzyName;
        }

        private List<String> rightFuzzyName;

        public List<String> getRightFuzzyName() {
            return this.rightFuzzyName;
        }

        private List<Integer> bannerList;

        public List<Integer> getBannerList() {
            return this.bannerList;
        }

        private Integer bannerSt;

        private Integer bannerEd;

        public Integer getBannerSt() {
            return this.bannerSt;
        }

        public Integer getBannerEd() {
            return this.bannerEd;
        }

        private List<String> richTextList;

        public List<String> getRichTextList() {
            return this.richTextList;
        }


        private List<String> fuzzyRichText;

        public List<String> getFuzzyRichText() {
            return this.fuzzyRichText;
        }

        private List<String> rightFuzzyRichText;

        public List<String> getRightFuzzyRichText() {
            return this.rightFuzzyRichText;
        }

        private List<String> lowerCaseList;

        public List<String> getLowerCaseList() {
            return this.lowerCaseList;
        }


        private List<String> fuzzyLowerCase;

        public List<String> getFuzzyLowerCase() {
            return this.fuzzyLowerCase;
        }

        private List<String> rightFuzzyLowerCase;

        public List<String> getRightFuzzyLowerCase() {
            return this.rightFuzzyLowerCase;
        }

        public ConditionBuilder idBetWeen(Integer idSt, Integer idEd) {
            this.idSt = idSt;
            this.idEd = idEd;
            return this;
        }

        public ConditionBuilder idGreaterEqThan(Integer idSt) {
            this.idSt = idSt;
            return this;
        }

        public ConditionBuilder idLessEqThan(Integer idEd) {
            this.idEd = idEd;
            return this;
        }


        public ConditionBuilder idList(Integer... id) {
            this.idList = solveNullList(id);
            return this;
        }

        public ConditionBuilder idList(List<Integer> id) {
            this.idList = id;
            return this;
        }

        public ConditionBuilder fuzzyName(List<String> fuzzyName) {
            this.fuzzyName = fuzzyName;
            return this;
        }

        public ConditionBuilder fuzzyName(String... fuzzyName) {
            this.fuzzyName = solveNullList(fuzzyName);
            return this;
        }

        public ConditionBuilder rightFuzzyName(List<String> rightFuzzyName) {
            this.rightFuzzyName = rightFuzzyName;
            return this;
        }

        public ConditionBuilder rightFuzzyName(String... rightFuzzyName) {
            this.rightFuzzyName = solveNullList(rightFuzzyName);
            return this;
        }

        public ConditionBuilder nameList(String... name) {
            this.nameList = solveNullList(name);
            return this;
        }

        public ConditionBuilder nameList(List<String> name) {
            this.nameList = name;
            return this;
        }

        public ConditionBuilder bannerBetWeen(Integer bannerSt, Integer bannerEd) {
            this.bannerSt = bannerSt;
            this.bannerEd = bannerEd;
            return this;
        }

        public ConditionBuilder bannerGreaterEqThan(Integer bannerSt) {
            this.bannerSt = bannerSt;
            return this;
        }

        public ConditionBuilder bannerLessEqThan(Integer bannerEd) {
            this.bannerEd = bannerEd;
            return this;
        }


        public ConditionBuilder bannerList(Integer... banner) {
            this.bannerList = solveNullList(banner);
            return this;
        }

        public ConditionBuilder bannerList(List<Integer> banner) {
            this.bannerList = banner;
            return this;
        }

        public ConditionBuilder fuzzyRichText(List<String> fuzzyRichText) {
            this.fuzzyRichText = fuzzyRichText;
            return this;
        }

        public ConditionBuilder fuzzyRichText(String... fuzzyRichText) {
            this.fuzzyRichText = solveNullList(fuzzyRichText);
            return this;
        }

        public ConditionBuilder rightFuzzyRichText(List<String> rightFuzzyRichText) {
            this.rightFuzzyRichText = rightFuzzyRichText;
            return this;
        }

        public ConditionBuilder rightFuzzyRichText(String... rightFuzzyRichText) {
            this.rightFuzzyRichText = solveNullList(rightFuzzyRichText);
            return this;
        }

        public ConditionBuilder richTextList(String... richText) {
            this.richTextList = solveNullList(richText);
            return this;
        }

        public ConditionBuilder richTextList(List<String> richText) {
            this.richTextList = richText;
            return this;
        }

        public ConditionBuilder fuzzyLowerCase(List<String> fuzzyLowerCase) {
            this.fuzzyLowerCase = fuzzyLowerCase;
            return this;
        }

        public ConditionBuilder fuzzyLowerCase(String... fuzzyLowerCase) {
            this.fuzzyLowerCase = solveNullList(fuzzyLowerCase);
            return this;
        }

        public ConditionBuilder rightFuzzyLowerCase(List<String> rightFuzzyLowerCase) {
            this.rightFuzzyLowerCase = rightFuzzyLowerCase;
            return this;
        }

        public ConditionBuilder rightFuzzyLowerCase(String... rightFuzzyLowerCase) {
            this.rightFuzzyLowerCase = solveNullList(rightFuzzyLowerCase);
            return this;
        }

        public ConditionBuilder lowerCaseList(String... lowerCase) {
            this.lowerCaseList = solveNullList(lowerCase);
            return this;
        }

        public ConditionBuilder lowerCaseList(List<String> lowerCase) {
            this.lowerCaseList = lowerCase;
            return this;
        }

        private <T> List<T> solveNullList(T... objs) {
            if (objs != null) {
                List<T> list = new ArrayList<>();
                for (T item : objs) {
                    if (item != null) {
                        list.add(item);
                    }
                }
                return list;
            }
            return null;
        }

        public ConditionBuilder build() {
            return this;
        }
    }

    public static class Builder {

        private ExampleVo obj;

        public Builder() {
            this.obj = new ExampleVo();
        }

        public Builder id(Integer id) {
            this.obj.setId(id);
            return this;
        }

        public Builder name(String name) {
            this.obj.setName(name);
            return this;
        }

        public Builder banner(Integer banner) {
            this.obj.setBanner(banner);
            return this;
        }

        public Builder richText(String richText) {
            this.obj.setRichText(richText);
            return this;
        }

        public Builder lowerCase(String lowerCase) {
            this.obj.setLowerCase(lowerCase);
            return this;
        }

        public ExampleVo build() {
            return obj;
        }
    }

}
